<template>
  <div class="container">
    <div class="header">
      <img class="avatar" :src="avatar" alt="" />
      <div class="user">
        <span class="username">{{ name }}</span>
        <span class="putonguser">普通用户</span>
      </div>
    </div>
    <div class="myAssets">我的资产</div>
    <div class="data">
      <div class="dataItem">
        <span class="count">￥0</span>
        <span class="text">余额</span>
      </div>
      <div class="dataItem">
        <span class="count">0</span>
        <span class="text">红包</span>
      </div>
      <div class="dataItem">
        <span class="count">0</span>
        <span class="text">优惠卷</span>
      </div>
      <div class="dataItem">
        <span class="count">0</span>
        <span class="text">积分</span>
      </div>
      <div class="dataItem">
        <span class="count">0</span>
        <span class="text">礼品卡</span>
      </div>
    </div>
    <div class="back back1"></div>
    <van-grid :column-num="3">
      <van-grid-item icon="orders-o" text="我的订单" />
      <van-grid-item icon="user-circle-o" text="账号管理" />
      <van-grid-item icon="phone-circle-o" text="我的手机号" />
      <van-grid-item icon="calendar-o" text="周六一起拼" />
      <van-grid-item icon="after-sale" text="售后服务" />
      <van-grid-item icon="envelop-o" text="邀请返利" />
      <van-grid-item icon="goods-collect-o" text="优先购" />
      <van-grid-item icon="gold-coin-o" text="积分中心" />
      <van-grid-item icon="diamond-o" text="会员俱乐部" />
      <van-grid-item icon="location-o" text="地址管理" />
      <van-grid-item icon="shield-o" text="支付安全" />
      <van-grid-item icon="service-o" text="帮助与客服" />
      <van-grid-item icon="records" text="意见反馈" />
      <van-grid-item icon="points" text="我的竞拍" />
    </van-grid>
    <div class="back back2"></div>
    <van-button type="primary" block @click="quitLogin">退出登录</van-button>
    <div class="back back3"></div>
  </div>
  <Following />
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
  name: 'Center'
})
</script>

<script lang="ts" setup>
import { useUserInfoStore } from '@/stores/modules/userInfo'
import { storeToRefs } from 'pinia'
import { useRouter } from 'vue-router'
import { Toast } from 'vant'
import 'vant/es/toast/style/index'
const router = useRouter()
const userInfoStore = useUserInfoStore()
const { avatar, name } = storeToRefs(userInfoStore)
const quitLogin = async () => {
  try {
    await userInfoStore.logout()
    router.push({
      path: '/'
    })
    Toast.success('退出登录成功')
  } catch (e) {}
}
</script>
<style scoped>
.container {
  width: 100%;
  height: 450px;
}
.container .header {
  width: 100%;
  height: 135px;
  display: flex;
  align-items: center;
  background-image: url(https://yanxuan.nosdn.127.net/5905098f74e04c39fa5e76ebb9ff591b.png);
}
.container .header .avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin-left: 20px;
}
.container .header .user {
  width: 154px;
  height: 70px;
  display: flex;
  flex-direction: column;
  color: white;
  margin-left: 15px;
  margin-top: 20px;
}
.container .header .user .username {
  font-size: 18px;
  margin-bottom: 5px;
}
.container .header .user .putonguser {
  font-size: 14px;
}
.myAssets {
  height: 53px;
  font-size: 14px;
  line-height: 53px;
  border-bottom: 2px solid #d9d9d9;
  margin-left: 16px;
}
.data {
  width: 100%;
  height: 98px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.data .dataItem {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 82px;
  /* justify-content: space-around; */
}
.data .dataItem .count {
  font-size: 16px;
  margin-bottom: 5px;
}
.data .dataItem .text {
  font-size: 12px;
}
.back {
  background-color: #f4f4f4;
}
.back.back1 {
  height: 10px;
}
.back.back2 {
  height: 30px;
}
.back.back3 {
  height: 70px;
}
/*

  <div class="data">
    <div class="dataItem">
      <span class="count">0</span>
      <span class="text">余额</span>
    </div>
  </div>
 */
</style>
